﻿var down;
var chour1, cmin1, csec1;

function Hours(data) {
    for (var i = 0; i < data.length; i++) if (data.substring(i, i + 1) == ":") break;
    return (data.substring(0, i));
}

function Minutes(data) {
    for (var i = 0; i < data.length; i++) if (data.substring(i, i + 1) == ":") break;
    return (data.substring(0, i));
}
function Seconds(data) {
    for (var i = 0; i < data.length; i++) if (data.substring(i, i + 1) == ":") break;
    return (data.substring(i + 1, data.length));
}
function Display(hour, min, sec) {
    var disp;
    if (hour <= 9) disp = " 0";
    else disp = " ";
    disp += hour + ":";
    if (min <= 9) disp += "0" + min + ":";
    else disp += min + ":";

    if (sec <= 9) disp += "0" + sec;
    else disp += sec;
    return (disp);
}

function Down(hour, min, sec, autionId, divid) {
    //    chour1 = hour
    //    cmin1 = min;
    //    csec1 = sec;
    clearTimeout(down);
    sec--;
    if (sec == -1) { sec = 59; min--; }
    if (min == -1) { min = 59; hour--; }
    if (hour == -1) { $("#" + divid).html(Display(0, 0, 0)); setInterval(function () { AJAXController.ARC('memberactionhandler', { action: 'auctionfinish', bid: autionId }, '', ''); }, 500); return; }
   
    $("#" + divid).html(Display(hour, min, sec));


    //if ((hour == 0) && (min == 0) && (sec == 0)) 
   // AJAXController.ARC('memberactionhandler', { action: 'auctionfinish', bid: autionId }, '', '');
    //else
    down = setInterval("Down(" + hour + "," + min + "," + sec + "," + autionId + ",'" + divid + "')", 1000);
    //  DownRepeat(autionId, divid);
}





